Native Control Panel for Switch

您所在的位置:网站首页 安卓 native Native Control Panel for Switch

Native Control Panel for Switch

#Native Control Panel for Switch| 来源: 网络整理| 查看: 265

Native control panels for switches are developed based on native code and support all switch categories.

Advantages Lightweight and free of frameworks such as React Native. Support all switch categories and apply to new products without app launching. Facilitate debugging during development.

Native Control Panel for SwitchNative Control Panel for SwitchNative Control Panel for Switch

How it works

Dependency

implementation 'com.tuya.smart:TuyaSwitchPanelPanel:1.0.1'

API description

void openDefaultPanel(Context context, String devId, MenuBean menuBean);

Parameters

Parameter Description context The context to start an activity. devId The device ID. menuBean Creates and displays custom menus and events.

menuBean can be set to null if it is not required.

MenuBean data model

Field Data type Description menuRes int The ID of a custom menu resource. menuItemId int The value of itemId for the custom menu. bundle Bundle The Bundle that passes custom data. You can use IDefaultPanelController.BUNDLE_KEY to get the value from Intent. activityClassName String The value of ClassName for a custom activity. Example: TestActivity.class.getName().

Java example

MenuBean menuBean = new MenuBean(); menuBean.setMenuRes(R.menu.common_menu); menuBean.setMenuItemId(R.id.check); Bundle bundle = new Bundle(); bundle.putString("DEV_ID_KEY", devId); menuBean.setBundle(bundle); menuBean.setActivityClassName(TestActivity.class.getName()); IDefaultPanelController defaultPanelController = PluginManager.service(IDefaultPanelController.class); defaultPanelController.usePanel(new HomeSDKPanel()); defaultPanelController.openDefaultPanel(context, devId, menuBean); Native control panels use startActivityForResult(Intent, IDefaultPanelController.REQUEST_CODE_DEFAULT_PANEL) to start a custom activity. Under onActivityResult, the application disables native control panels if (requestCode == IDefaultPanelController.REQUEST_CODE_DEFAULT_PANEL && resultCode == RESULT_OK) is true.


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3